/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.comsrv.controller;

import com.ykht.proj.common.core.util.R;
import com.ykht.proj.common.security.annotation.Inner;
import com.ykht.proj.comsrv.utils.msgutil.MsgUtil;
import com.ykht.proj.comsrv.vo.MsgVo;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author proj
 * @date 2018/11/14
 * <p>
 * 手机验证码
 */
@RestController
@AllArgsConstructor
@RequestMapping("/mobile")
@Api(value = "mobile", tags = "发送短信")
public class MobileController {

	@Autowired
	private MsgUtil msgUtil;

	@Inner(value = false)
	@PostMapping("/sendMsg")
	public R sendSmsCode(@RequestBody MsgVo msgVo) {
		try {
			msgUtil.sendSms(msgVo.getMobile(),msgVo.getMsg());
			return R.ok();
		} catch (Exception e) {
			e.printStackTrace();
			return R.failed();
		}
	}

}
